package timetabling;

import generalEvolutionaryAlgorithm.EAValue;

public class TimetablingValue implements EAValue {
	private int lastTimeSlotADay;
	private int onlyOneLectureADay;
	private int longConsecutiveLectures;
	private int numberStudentsHaveMoreLecturesAtSameTime;
	private int unscheduledEvents;
	private int eventTakesPlaceInRoomWithoutNeededFeatures;
	public TimetablingValue(
			int lastTimeSlotADay,
			int onlyOneLectureADay,
			int longConsecutiveLectures,
			int numberStudentsHaveMoreLecturesAtSameTime,
			int unscheduledEvents,
			int eventTakesPlaceInRoomWithoutNeededFeatures){
		this.lastTimeSlotADay = lastTimeSlotADay;
		this.onlyOneLectureADay = onlyOneLectureADay;
		this.longConsecutiveLectures = longConsecutiveLectures;
		this.numberStudentsHaveMoreLecturesAtSameTime = numberStudentsHaveMoreLecturesAtSameTime;
		this.unscheduledEvents = unscheduledEvents;
		this.eventTakesPlaceInRoomWithoutNeededFeatures = eventTakesPlaceInRoomWithoutNeededFeatures;
	}
	
	@Override
	public int compareTo(EAValue other) {
		TimetablingValue otherT = (TimetablingValue) other;
		if(unscheduledEvents != otherT.unscheduledEvents){
			return Integer.valueOf(unscheduledEvents).compareTo(otherT.unscheduledEvents);
		}
		if(eventTakesPlaceInRoomWithoutNeededFeatures != otherT.eventTakesPlaceInRoomWithoutNeededFeatures){
			return Integer.valueOf(eventTakesPlaceInRoomWithoutNeededFeatures).compareTo(otherT.eventTakesPlaceInRoomWithoutNeededFeatures);
		}
		if(numberStudentsHaveMoreLecturesAtSameTime != otherT.numberStudentsHaveMoreLecturesAtSameTime){
			return Integer.valueOf(numberStudentsHaveMoreLecturesAtSameTime).compareTo(otherT.numberStudentsHaveMoreLecturesAtSameTime);
		}
		int vthis = longConsecutiveLectures + onlyOneLectureADay + lastTimeSlotADay;
		int vother = otherT.longConsecutiveLectures + otherT.onlyOneLectureADay + otherT.lastTimeSlotADay;
		if(vthis != vother){
			return Integer.valueOf(vthis).compareTo(vother);
		}
		return 0;
	}

	@Override
	public String toString(){
		return "\nlast time slot a day: " + lastTimeSlotADay + "\n"
					+ "only one lecture a day: " + onlyOneLectureADay + "\n"
	                + "long consecutive lectures: " + longConsecutiveLectures + "\n"
	                + "number students have more lectures at same time: " + numberStudentsHaveMoreLecturesAtSameTime + "\n"
	                + "unscheduled Events: " + unscheduledEvents + "\n"
	                + "event takes place in room without needed features: " + eventTakesPlaceInRoomWithoutNeededFeatures + "\n";
	}
}
